This present invention relates to character conversion technology, and in particular to a method for converting character codes between two different character code sets.
Character encoding/decoding is mainly utilized in multilingual applications. The multilingual applications may be employed in many devices, such as computers, Personal Digital Assistants (PDAs), or mobile handheld devices.
A conventional method of converting character codes between two different character code sets is to establish one-to-one mapping tables. The established mapping tables generally contain records of character codes of two different character code sets, that is, a source character code set and a destination character code set.
For example, if a source character code set is Arabic ISO and a destination character code set is Unicode-UCS (Universal Character Set), a one-to-one mapping table is established for character code conversion. In this example, because Arabic ISO (International Organization for Standardization) character set includes 209 characters and Arabic ISO/Unicode-UCS uses 16 bit (2 bytes) representation, a one-way mapping table requires (209)×(2+2)=836 bytes. A one-way mapping table can only accomplish one-way conversion, that is, from Arabic ISO to Unicode or from Unicode to Arabic ISO. If two-way conversion is required, that is, from Arabic ISO to Unicode and from Unicode to Arabic ISO, the size of the mapping table must be doubled to 836×2=1672 bytes.
Furthermore, the efficiency of character conversion can be viewed as the efficiency of a binary search in the mapping table. The complexity is log2N, N=209.
Since different languages may adopt different character code sets to encode characters, in the device supporting multilingual applications, characters have to be converted from one character code set to another, causing character conversion problems. Particularly, in some devices, such as mobile handhelds, the memory size and the calculation ability of central processing unit (CPU) may be limited. Thus, conventional methods are not satisfactory for many devices.